/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package towerz.states;

import java.util.Vector;

/**
 *
 * @author LegACy
 */
public class StateFactory {
	/**
	 * Protected constructor
	 */
	protected StateFactory() {}

	public static GameState createState(int id, Vector parameters) {
		//Default value
		GameState NewState = null;

		//Based on id
		switch(id) {
		case GameState.FRONT:
			//Create front state
			NewState = new StateFront();
			break;

		case GameState.LEVELS:
			//Create level selection state
			if(parameters != null)
				NewState = new StateLevel(((Integer)parameters.elementAt(0)).intValue());
			else
				NewState = new StateLevel();
			break;

		case GameState.GAME:
			//Create game state
			NewState = new StateGame(Integer.parseInt(parameters.elementAt(0).toString()));
			break;
            
        case GameState.PAUSE:
            //Create Pause State
			if (parameters != null) NewState = new StatePause(((Integer)parameters.elementAt(0)).intValue());
            else					NewState = new StatePause();
			break;

		case GameState.GAME_OVER:
			//Create GameOver State
			NewState = new StateGameOver(Integer.parseInt(parameters.elementAt(0).toString()));
			break;

		case GameState.CREDITS:
			//Create GameOver State
			NewState = new StateCredit();
			break;

		case GameState.SPLASH:
			//Create GameOver State
			NewState = new StateSplash();
			break;

		case GameState.HELP:
			//Create help State
			NewState = new StateHelp();
			break;

		case GameState.LOADING:
			//Create loading State
			NewState = new StateLoading(new Integer(Integer.parseInt(parameters.elementAt(0).toString())));
			break;
		
		case GameState.HIGH_SCORE:
			//Create highscore state
			if(parameters != null) 	NewState = new StateHighScore(parameters);
			else					NewState = new StateHighScore();
			break;
		}

		//Return the state
		return NewState;
	}
}
